package com.cqut.familiarity.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.io.Serializable;
import java.util.List;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author atao
 * @since 2021-06-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_question")
@ApiModel(value="Question对象", description="")
public class Question implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "ID")
    @TableId(value = "id", type = IdType.ID_WORKER_STR)
    private String id;

    @ApiModelProperty(value = "问题")
    private String question;

    @ApiModelProperty(value = "0：单选；1：多选;；2：填空；")
    private String type;

    @ApiModelProperty(value = "选项或者文本，根据type决定")
    private String options;

    @ApiModelProperty(value = "是否必填  0:否 1:是")
    private String isMandatory;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date modifyTime;

    @ApiModelProperty(value = "逻辑删除")
    @TableField(fill = FieldFill.INSERT)
    private String isDeleted;

    @ApiModelProperty(value = "1:N神经质 2：E外向性 3：O开放性 4：A服从性 5：C严谨性")
    private String category;

    @ApiModelProperty(value = "是否为反向题目 0:否 1:是")
    private String isReverse;

    @TableField(exist = false)
    private List<String> listOptions;

    /**
     * 解析字符串类型的选项为链表
     */
    public void optionsToList(){
        String[] ans = this.options.split(",");
        this.listOptions = new ArrayList<>();
        for (String res:ans){
            this.listOptions.add(res);
        }
    }


}
